import Vue from 'vue';
import Vuex from 'vuex';
import getters from './getters';
import actions from './actions';
import mutations from './mutations';

Vue.use(Vuex);

const initUserInfo = JSON.parse(localStorage.getItem('user')) || {};
const initToken = localStorage.getItem('token') || '';

export default new Vuex.Store({
  state: {
    userInfo: initUserInfo,
    token: initToken
  },
  getters,
  actions,
  mutations,
  modules: {
    permissionClassify: require('./modules/admin/permission-classify').default,
    permission: require('./modules/admin/permission').default,
    role: require('./modules/admin/role').default,
  }
});
